<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	java.lang.String path = request.getContextPath();
	

%>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台管理员登录</title>
	<link rel="stylesheet" href="<%=path%>/back/util/css/reset.css">
	<link rel="stylesheet" href="<%=path%>/back/util/css/app.css">
	<script type="text/javascript" src="<%=path%>/back/util/js/jq-1.12.4.min.js"></script>
	<script type="text/javascript" src="<%=path%>/back/util/js/jquery.cookie.js"></script>
	<style>
		html,body{
			height: 100%;
			width: 100%;
			background-color:#34485c;
		}
	</style>
</head>

<body>
	<div class="max-container">
		<div class="container juzhong">
			<div class="content-area juzhong">
				<div class="content-left-part">
					<img src="<%=path%>/back/util/image/loginleft.png" alt=""/>
				</div>
				<div class="content-right-part">
					<span class="date-time"></span>
					<ul class="tab-nav">
						<li class="active"><a href="javascript:void(0)" data="1">管理员登录</a></li>
					</ul>
					<ul class="tab-content">
						<li>
							<form action="">
								<div class="input-group">
									<label for="user"><img src="<%=path%>/back/util/image/usericon.png" alt="" width="22" height="25"></label>
									<input type="text" id="user" placeholder="请输入用户名" name="username" autocomplete="off">
								</div>
								<div class="input-group">
									<label for="pwd" style="width: 19px;height: 24px"><img src="<%=path%>/back/util/image/passwordicon.png"></label>
									<input type="password" id="pwd" placeholder="请输入密码" name="pwd" autocomplete="off">
								</div>
								<div class="checkbox-group">
									<label for="checkbox" ><i></i>记住密码</label>
									<input type="checkbox" id="checkbox" name="checkbox">
								</div>
								<button class="btn-style btn-color" id="submit" type="submit">登录</button>
							</form>
						</li>
					</ul>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
$(function(){
	//验证是否有记住密码
	if ($.cookie("rmbUser") == "true") { 
		$("#checkbox").attr("checked", true); 
		$("#user").val($.cookie("userName")); 
		$("#pwd").val($.cookie("passWord"));
		$('.checkbox-group label i').css({"background-image":"url("+'<%=path%>/back/util'+"/image/jizhumima.png)"})
	} 
	$('.checkbox-group label').click(function(){
		if($("input[type='checkbox']").is(':checked')){
			$('.checkbox-group label i').css({"background-image":"url("+'<%=path%>/back/util'+"/image/jizhumima0.png)"})
		}else{
			$('.checkbox-group label i').css({"background-image":"url("+'<%=path%>/back/util'+"/image/jizhumima.png)"})
		}
	})
})
</script>
<script>
	document.getElementById('submit').onclick=function(e){
		e.preventDefault();
		var name=$('#user').val();
		var pass=$('#pwd').val();
		
		if($("input[type='checkbox']").is(':checked')){
			$.cookie("rmbUser", "true", { expires: 7 }); // 存储一个带7天期限的 cookie 
			$.cookie("userName", name, { expires: 7 }); // 存储一个带7天期限的 cookie 
			$.cookie("passWord", pass, { expires: 7 }); // 存储一个带7天期限的 cookie 
			
		}else{
			$.cookie("rmbUser", "false", { expires: -1 }); 
			$.cookie("userName", '', { expires: -1 }); 
			$.cookie("passWord", '', { expires: -1 }); 
		}
		$.post('tologin.do',{'name':name,'pass':pass},function(date){
			if(date.code=='0'){
				window.location.href="/interwar/manage/tomain.do";
			}else if(date.code=='1'){
				alert(date.msg)
			}else{
				alert('服务器异常');
			}
					
		});
	}
</script>
</html>